home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 422_02 / dosutil / equip.c < prev    next >
C/C++ Source or Header  |  1994-03-20  |  2KB  |  67 lines

  1. /*
  2.  * Program to display the equipment configuration installed in
  3.  * an IBM/PC or compatable system.
  4.  *
  5.  * This demonstrates the use of inline assembly language routines,
  6.  * which are used to obtain information from the IBM/PC BIOS.
  7.  *
  8.  * Copyright 1989-1994 Dave Dunfield
  9.  * All rights reserved.
  10.  *
  11.  * Compile command: cc equip -fop
  12.  */
  13. #include <stdio.h>
  14.  
  15. /* Video adapter display text */
  16. char *ivmode[] = { "Unknown", "Color-40", "Color-80", "Monochrome" };
  17.  
  18. /*
  19.  * Main program to display the equipment installed in an IBM/PC
  20.  */
  21. main()
  22. {
  23.     int equip, hdrives, i;
  24.  
  25.     equip = get_equip();
  26.     hdrives = 0;
  27.     for(i=0x80; i < (0x80+26); ++i) {
  28.         if(!test_drive(i))
  29.             ++hdrives; }
  30.     printf("Base system memory=%uK\n", get_mem());
  31.     printf("Math co-processor%sinstalled\n", (equip & 2) ? " " : " not ");
  32.     printf("Game adaptor%sinstalled\n", (equip & 0x1000) ? " " : " not ");
  33.     printf("Startup video is %s\n", ivmode[(equip >> 4) & 3]);
  34.     printf("%u Floppy disk drive(s)\n", (equip & 1) && (((equip >> 6) & 3) + 1));
  35.     printf("%u Hard disk drive(s)\n", hdrives);
  36.     printf("%u Serial port(s)\n", (equip >> 9) & 7);
  37.     printf("%u Parallel port(s)\n", (equip >> 14) & 3);
  38. }
  39.  
  40. /*
  41.  * Get the equipment configuration from BIOS
  42.  */
  43. get_equip() asm
  44. {
  45.         INT        11h            ; Get equipment
  46. }
  47.  
  48. /*
  49.  * Get size of installed memory from BIOS
  50.  */
  51. get_mem() asm
  52. {
  53.         INT        12h            ; Get memory size
  54. }
  55.  
  56. /*
  57.  * Test for existance of a hard drive
  58.  */
  59. test_drive(drive) asm
  60. {
  61.         MOV        DL,4[BP]    ; Get drive id
  62.         MOV        AH,10h        ; Drive status function
  63.         INT        13h            ; Ask BIOS
  64.         MOV        AL,AH        ; Get value
  65.         XOR        AH,AH        ; Zero high
  66. }
  67.